package com.demo.account;

public class Account {
    private String actName;
    private double balance;

    public String getActName() {
        return actName;
    }

    public Account(String actName, double balance) {
        this.actName = actName;
        this.balance = balance;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double withDraw(double money) {
        Object o = new Object();
        synchronized (actName) {
            double balance = this.getBalance();
            double after = balance - money;
//            try {
//                Thread.sleep(200);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
            this.setBalance(after);
            return after;
        }
    }
}
